﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using LIM.controller;
using LIM.model;

namespace LIM.report
{
    public partial class frm_RPHDNguyenTac : Form
    {
        public frm_RPHDNguyenTac()
        {
            InitializeComponent();
        }
        int RowIDHopDong = 2;
        DanhMucHopDongController controller = new DanhMucHopDongController();
        private void frm_RPHDDVKHCN_Load(object sender, EventArgs e)
        {
            if (RowIDHopDong != 0)
            {
                tbl_CRM_HopDong hopdong = controller.LoadHopDongByRowID(RowIDHopDong);
                string KhachHang = "";
                if (controller.GetKH(hopdong.RowIDKhachHang) != null && controller.GetKH(hopdong.RowIDKhachHang) != "")
                {
                    KhachHang = controller.GetKH(hopdong.RowIDKhachHang);
                }
                string NguoiLienHe = "";
                if (controller.GetLienHe(hopdong.RowIDLienLac) != null && controller.GetLienHe(hopdong.RowIDLienLac) != "")
                {
                    NguoiLienHe = controller.GetLienHe(hopdong.RowIDLienLac);
                }
                #region Paramater
                ReportParameter[] report = new ReportParameter[]
                {
                    new ReportParameter("SoHopDong",hopdong.MaHopDong),
                    new ReportParameter("NguoiLienHe",NguoiLienHe),
                    new ReportParameter("KhachHang",KhachHang),
                    new ReportParameter("ChucVu",hopdong.ChucVu),
                    new ReportParameter("DiaChi",hopdong.DiaChi),
                    new ReportParameter("DT",hopdong.SoDienThoai),
                    new ReportParameter("Fax",hopdong.SoFax),
                    new ReportParameter("MST",hopdong.MaSoThue),
                    new ReportParameter("STK",hopdong.TaiKhoanNganHang),
                    new ReportParameter("NguoiTao",""),
                    new ReportParameter("HomNay",DateTime.Now.ToString()),
                    new ReportParameter("TuNgay",hopdong.ThoiGianHieuLuc_Tu.HasValue ? hopdong.ThoiGianHieuLuc_Tu.Value.ToString() : ""),
                    new ReportParameter("DenNgay",hopdong.ThoiGianHieuLuc_Den.HasValue ? hopdong.ThoiGianHieuLuc_Den.Value.ToString() : ""),
                };
                #endregion

                reportViewer1.LocalReport.SetParameters(report);
                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                this.reportViewer1.RefreshReport();
            }
        }
    }
}
